// Copyright 2019 The TCMalloc Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "absl/types/span.h"
#include "tcmalloc/common.h"
#include "tcmalloc/internal/config.h"
#include "tcmalloc/size_class_info.h"

GOOGLE_MALLOC_SECTION_BEGIN
namespace tcmalloc {
namespace tcmalloc_internal {

// Columns in the following tables:
// - bytes: size of the size class
// - pages: number of pages per span
// - batch: preferred number of objects for transfers between caches
// - class: size class number
// - objs: number of objects per span
// - waste/fixed: fixed per-size-class overhead due to end-of-span fragmentation
//   and other factors. For instance, if we have a 96 byte size class, and use
//   a single 8KiB page, then we will hold 85 objects per span, and have 32
//   bytes left over. There is also a fixed component of 64 bytes of TCMalloc
//   metadata per span. Together, the fixed overhead would be wasted/allocated
//   = (32 + 64) / (8192 - 32) ~= 1.2%.
// - waste/sampling: overhead due to heap sampling
//   (rounding to page size, proxy object, metadata).
// - inc: increment from the previous size class. This caps the dynamic
//   overhead component based on mismatches between the number of bytes
//   requested and the number of bytes provided by the size class. Together
//   they sum to the total overhead; for instance if you asked for a 50-byte
//   allocation that rounds up to a 64-byte size class, the dynamic overhead
//   would be 28%, and if waste were 22% it would mean (on average) 25 bytes
//   of overhead for allocations of that size.

// clang-format off
#if defined(__cpp_aligned_new) && __STDCPP_DEFAULT_NEW_ALIGNMENT__ <= 8
#if TCMALLOC_PAGE_SHIFT == 13
static_assert(kMaxSize == 262144, "kMaxSize mismatch");
static constexpr SizeClassAssumptions Assumptions{
  .has_expanded_classes = true,
  .span_size = 64,
  .sampling_interval = 2097152,
  .large_size = 1024,
  .large_size_alignment = 128,
};
static constexpr SizeClassInfo List[] = {
//                                         |    waste     |
//  bytes pages batch   class  objs |fixed sampling|    inc
  {     0,    0,    0},  //  0     0  0.00%    0.00%   0.00%
  {     8,    1,   32},  //  1  1024  0.78%    0.42%   0.00%
  {    16,    1,   32},  //  2   512  0.78%    0.42% 100.00%
  {    24,    1,   32},  //  3   341  0.87%    0.42%  50.00%
  {    32,    1,   32},  //  4   256  0.78%    0.42%  33.33%
  {    40,    1,   32},  //  5   204  1.16%    0.42%  25.00%
  {    48,    1,   32},  //  6   170  1.16%    0.42%  20.00%
  {    56,    1,   32},  //  7   146  0.97%    0.42%  16.67%
  {    64,    1,   32},  //  8   128  0.78%    0.42%  14.29%
  {    72,    1,   32},  //  9   113  1.45%    0.42%  12.50%
  {    80,    1,   32},  // 10   102  1.16%    0.42%  11.11%
  {    88,    1,   32},  // 11    93  0.87%    0.42%  10.00%
  {    96,    1,   32},  // 12    85  1.16%    0.42%   9.09%
  {   104,    1,   32},  // 13    78  1.74%    0.42%   8.33%
  {   112,    1,   32},  // 14    73  0.97%    0.42%   7.69%
  {   120,    1,   32},  // 15    68  1.16%    0.42%   7.14%
  {   128,    1,   32},  // 16    64  0.78%    0.42%   6.67%
  {   136,    1,   32},  // 17    60  1.16%    0.42%   6.25%
  {   144,    1,   32},  // 18    56  2.33%    0.42%   5.88%
  {   152,    1,   32},  // 19    53  2.42%    0.42%   5.56%
  {   160,    1,   32},  // 20    51  1.16%    0.42%   5.26%
  {   168,    1,   32},  // 21    48  2.33%    0.42%   5.00%
  {   184,    1,   32},  // 22    44  1.94%    0.42%   9.52%
  {   192,    1,   32},  // 23    42  2.33%    0.42%   4.35%
  {   208,    1,   32},  // 24    39  1.74%    0.42%   8.33%
  {   224,    1,   32},  // 25    36  2.33%    0.42%   7.69%
  {   240,    1,   32},  // 26    34  1.16%    0.42%   7.14%
  {   256,    1,   32},  // 27    32  0.78%    0.42%   6.67%
  {   264,    1,   32},  // 28    31  0.87%    0.42%   3.12%
  {   280,    1,   32},  // 29    29  1.65%    0.42%   6.06%
  {   312,    1,   32},  // 30    26  1.74%    0.42%  11.43%
  {   336,    1,   32},  // 31    24  2.33%    0.42%   7.69%
  {   352,    1,   32},  // 32    23  1.94%    0.42%   4.76%
  {   384,    1,   32},  // 33    21  2.33%    0.42%   9.09%
  {   408,    1,   32},  // 34    20  1.16%    0.42%   6.25%
  {   448,    1,   32},  // 35    18  2.33%    0.42%   9.80%
  {   480,    1,   32},  // 36    17  1.16%    0.42%   7.14%
  {   512,    1,   32},  // 37    16  0.78%    0.42%   6.67%
  {   576,    1,   32},  // 38    14  2.33%    0.42%  12.50%
  {   640,    1,   32},  // 39    12  6.98%    0.43%  11.11%
  {   704,    1,   32},  // 40    11  6.20%    0.43%  10.00%
  {   768,    1,   32},  // 41    10  6.98%    0.43%   9.09%
  {   896,    1,   32},  // 42     9  2.33%    0.42%  16.67%
  {  1024,    1,   32},  // 43     8  0.78%    0.42%  14.29%
  {  1152,    2,   32},  // 44    14  1.95%    0.42%  12.50%
  {  1280,    2,   32},  // 45    12  6.61%    0.43%  11.11%
  {  1408,    2,   32},  // 46    11  5.84%    0.43%  10.00%
  {  1536,    2,   32},  // 47    10  6.61%    0.43%   9.09%
  {  1792,    2,   32},  // 48     9  1.95%    0.43%  16.67%
  {  2048,    2,   32},  // 49     8  0.39%    0.42%  14.29%
  {  2304,    2,   28},  // 50     7  1.95%    0.43%  12.50%
  {  2688,    2,   24},  // 51     6  1.95%    0.43%  16.67%
  {  3200,    2,   20},  // 52     5  2.72%    0.43%  19.05%
  {  3584,    4,   18},  // 53     9  1.75%    0.43%  12.00%
  {  4096,    1,   16},  // 54     2  0.78%    0.43%  14.29%
  {  4736,    3,   13},  // 55     5  3.90%    0.43%  15.62%
  {  5376,    2,   12},  // 56     3  1.95%    0.43%  13.51%
  {  6144,    3,   10},  // 57     4  0.26%    0.42%  14.29%
  {  6528,    4,   10},  // 58     5  0.58%    0.43%   6.25%
  {  7168,    7,    9},  // 59     8  0.11%    0.42%   9.80%
  {  8192,    1,    8},  // 60     1  0.78%    0.03%  14.29%
  {  9472,    5,    6},  // 61     4  7.64%    0.85%  15.62%
  { 10240,    4,    6},  // 62     3  6.43%    0.85%   8.11%
  { 12288,    3,    5},  // 63     2  0.26%    0.82%  20.00%
  { 13568,    5,    4},  // 64     3  0.78%    0.82%  10.42%
  { 14336,    7,    4},  // 65     4  0.11%    0.82%   5.66%
  { 16384,    2,    4},  // 66     1  0.39%    0.03%  14.29%
  { 20480,    5,    3},  // 67     2  0.16%    1.21%  25.00%
  { 24576,    3,    2},  // 68     1  0.26%    0.03%  20.00%
  { 28672,    7,    2},  // 69     2  0.11%    1.60%  16.67%
  { 32768,    4,    2},  // 70     1  0.19%    0.03%  14.29%
  { 40960,    5,    2},  // 71     1  0.16%    0.03%  25.00%
  { 49152,    6,    2},  // 72     1  0.13%    0.03%  20.00%
  { 57344,    7,    2},  // 73     1  0.11%    0.03%  16.67%
  { 65536,    8,    2},  // 74     1  0.10%    0.03%  14.29%
  { 73728,    9,    2},  // 75     1  0.09%    0.03%  12.50%
  { 81920,   10,    2},  // 76     1  0.08%    0.03%  11.11%
  { 98304,   12,    2},  // 77     1  0.07%    0.03%  20.00%
  {114688,   14,    2},  // 78     1  0.06%    0.03%  16.67%
  {131072,   16,    2},  // 79     1  0.05%    0.03%  14.29%
  {139264,   17,    2},  // 80     1  0.05%    0.03%   6.25%
  {155648,   19,    2},  // 81     1  0.04%    0.03%  11.76%
  {180224,   22,    2},  // 82     1  0.04%    0.03%  15.79%
  {204800,   25,    2},  // 83     1  0.03%    0.03%  13.64%
  {229376,   28,    2},  // 84     1  0.03%    0.03%  12.00%
  {262144,   32,    2},  // 85     1  0.02%    0.03%  14.29%
};
#elif TCMALLOC_PAGE_SHIFT == 15
static_assert(kMaxSize == 262144, "kMaxSize mismatch");
static constexpr SizeClassAssumptions Assumptions{
  .has_expanded_classes = true,
  .span_size = 64,
  .sampling_interval = 2097152,
  .large_size = 1024,
  .large_size_alignment = 128,
};
static constexpr SizeClassInfo List[] = {
//                                         |    waste     |
//  bytes pages batch   class  objs |fixed sampling|    inc
  {     0,    0,    0},  //  0     0  0.00%    0.00%   0.00%
  {     8,    1,   32},  //  1  4096  0.19%    1.60%   0.00%
  {    16,    1,   32},  //  2  2048  0.19%    1.60% 100.00%
  {    24,    1,   32},  //  3  1365  0.22%    1.60%  50.00%
  {    32,    1,   32},  //  4  1024  0.19%    1.60%  33.33%
  {    40,    1,   32},  //  5   819  0.22%    1.60%  25.00%
  {    48,    1,   32},  //  6   682  0.29%    1.60%  20.00%
  {    56,    1,   32},  //  7   585  0.22%    1.60%  16.67%
  {    64,    1,   32},  //  8   512  0.19%    1.60%  14.29%
  {    72,    1,   32},  //  9   455  0.22%    1.60%  12.50%
  {    80,    1,   32},  // 10   409  0.34%    1.60%  11.11%
  {    88,    1,   32},  // 11   372  0.29%    1.60%  10.00%
  {    96,    1,   32},  // 12   341  0.29%    1.60%   9.09%
  {   104,    1,   32},  // 13   315  0.22%    1.60%   8.33%
  {   112,    1,   32},  // 14   292  0.39%    1.60%   7.69%
  {   120,    1,   32},  // 15   273  0.22%    1.60%   7.14%
  {   128,    1,   32},  // 16   256  0.19%    1.60%   6.67%
  {   144,    1,   32},  // 17   227  0.44%    1.60%  12.50%
  {   160,    1,   32},  // 18   204  0.58%    1.60%  11.11%
  {   176,    1,   32},  // 19   186  0.29%    1.60%  10.00%
  {   192,    1,   32},  // 20   170  0.58%    1.60%   9.09%
  {   208,    1,   32},  // 21   157  0.54%    1.60%   8.33%
  {   224,    1,   32},  // 22   146  0.39%    1.60%   7.69%
  {   240,    1,   32},  // 23   136  0.58%    1.60%   7.14%
  {   256,    1,   32},  // 24   128  0.19%    1.60%   6.67%
  {   280,    1,   32},  // 25   117  0.22%    1.60%   9.38%
  {   312,    1,   32},  // 26   105  0.22%    1.60%  11.43%
  {   344,    1,   32},  // 27    95  0.46%    1.60%  10.26%
  {   376,    1,   32},  // 28    87  0.37%    1.60%   9.30%
  {   400,    1,   32},  // 29    81  1.32%    1.60%   6.38%
  {   448,    1,   32},  // 30    73  0.39%    1.60%  12.00%
  {   512,    1,   32},  // 31    64  0.19%    1.60%  14.29%
  {   576,    1,   32},  // 32    56  1.75%    1.60%  12.50%
  {   640,    1,   32},  // 33    51  0.58%    1.60%  11.11%
  {   704,    1,   32},  // 34    46  1.36%    1.60%  10.00%
  {   768,    1,   32},  // 35    42  1.75%    1.60%   9.09%
  {   896,    1,   32},  // 36    36  1.75%    1.60%  16.67%
  {  1024,    1,   32},  // 37    32  0.19%    1.60%  14.29%
  {  1152,    1,   32},  // 38    28  1.75%    1.60%  12.50%
  {  1280,    1,   32},  // 39    25  2.53%    1.60%  11.11%
  {  1536,    1,   32},  // 40    21  1.75%    1.60%  20.00%
  {  1664,    1,   32},  // 41    19  3.70%    1.60%   8.33%
  {  1920,    1,   32},  // 42    17  0.58%    1.60%  15.38%
  {  2048,    1,   32},  // 43    16  0.19%    1.60%   6.67%
  {  2176,    1,   30},  // 44    15  0.58%    1.60%   6.25%
  {  2432,    1,   26},  // 45    13  3.70%    1.60%  11.76%
  {  2688,    1,   24},  // 46    12  1.75%    1.60%  10.53%
  {  2944,    1,   22},  // 47    11  1.36%    1.60%   9.52%
  {  3200,    1,   20},  // 48    10  2.53%    1.60%   8.70%
  {  3584,    1,   18},  // 49     9  1.75%    1.60%  12.00%
  {  4096,    1,   16},  // 50     8  0.19%    1.60%  14.29%
  {  4608,    1,   14},  // 51     7  1.75%    1.60%  12.50%
  {  5376,    1,   12},  // 52     6  1.75%    1.60%  16.67%
  {  6528,    1,   10},  // 53     5  0.58%    1.60%  21.43%
  {  8192,    1,    8},  // 54     4  0.19%    1.60%  25.49%
  {  9344,    2,    7},  // 55     7  0.29%    1.60%  14.06%
  { 10880,    1,    6},  // 56     3  0.58%    1.60%  16.44%
  { 13056,    2,    5},  // 57     5  0.49%    1.60%  20.00%
  { 13952,    3,    4},  // 58     7  0.72%    1.60%   6.86%
  { 16384,    1,    4},  // 59     2  0.19%    1.60%  17.43%
  { 19072,    3,    3},  // 60     5  3.06%    1.62%  16.41%
  { 21760,    2,    3},  // 61     3  0.49%    1.60%  14.09%
  { 24576,    3,    2},  // 62     4  0.07%    1.60%  12.94%
  { 28672,    7,    2},  // 63     8  0.03%    1.60%  16.67%
  { 32768,    1,    2},  // 64     1  0.19%    0.03%  14.29%
  { 38144,    5,    2},  // 65     4  6.91%    3.28%  16.41%
  { 40960,    4,    2},  // 66     3  6.30%    3.28%   7.38%
  { 49152,    3,    2},  // 67     2  0.07%    3.16%  20.00%
  { 57344,    7,    2},  // 68     4  0.03%    3.16%  16.67%
  { 65536,    2,    2},  // 69     1  0.10%    0.03%  14.29%
  { 81920,    5,    2},  // 70     2  0.04%    4.72%  25.00%
  { 98304,    3,    2},  // 71     1  0.07%    0.03%  20.00%
  {114688,    7,    2},  // 72     2  0.03%    6.28%  16.67%
  {131072,    4,    2},  // 73     1  0.05%    0.03%  14.29%
  {163840,    5,    2},  // 74     1  0.04%    0.03%  25.00%
  {196608,    6,    2},  // 75     1  0.03%    0.03%  20.00%
  {229376,    7,    2},  // 76     1  0.03%    0.03%  16.67%
  {262144,    8,    2},  // 77     1  0.02%    0.03%  14.29%
};
#elif TCMALLOC_PAGE_SHIFT == 18
static_assert(kMaxSize == 262144, "kMaxSize mismatch");
static constexpr SizeClassAssumptions Assumptions{
  .has_expanded_classes = true,
  .span_size = 64,
  .sampling_interval = 2097152,
  .large_size = 1024,
  .large_size_alignment = 128,
};
static constexpr SizeClassInfo List[] = {
//                                         |    waste     |
//  bytes pages batch   class  objs |fixed sampling|    inc
  {     0,    0,    0},  //  0     0  0.00%    0.00%   0.00%
  {     8,    1,   32},  //  1 32768  0.02%   12.53%   0.00%
  {    16,    1,   32},  //  2 16384  0.02%   12.53% 100.00%
  {    24,    1,   32},  //  3 10922  0.03%   12.53%  50.00%
  {    32,    1,   32},  //  4  8192  0.02%   12.53%  33.33%
  {    40,    1,   32},  //  5  6553  0.03%   12.53%  25.00%
  {    48,    1,   32},  //  6  5461  0.03%   12.53%  20.00%
  {    56,    1,   32},  //  7  4681  0.03%   12.53%  16.67%
  {    64,    1,   32},  //  8  4096  0.02%   12.53%  14.29%
  {    72,    1,   32},  //  9  3640  0.05%   12.53%  12.50%
  {    80,    1,   32},  // 10  3276  0.05%   12.53%  11.11%
  {    88,    1,   32},  // 11  2978  0.05%   12.53%  10.00%
  {    96,    1,   32},  // 12  2730  0.05%   12.53%   9.09%
  {   104,    1,   32},  // 13  2520  0.05%   12.53%   8.33%
  {   112,    1,   32},  // 14  2340  0.05%   12.53%   7.69%
  {   128,    1,   32},  // 15  2048  0.02%   12.53%  14.29%
  {   144,    1,   32},  // 16  1820  0.05%   12.53%  12.50%
  {   160,    1,   32},  // 17  1638  0.05%   12.53%  11.11%
  {   176,    1,   32},  // 18  1489  0.05%   12.53%  10.00%
  {   192,    1,   32},  // 19  1365  0.05%   12.53%   9.09%
  {   208,    1,   32},  // 20  1260  0.05%   12.53%   8.33%
  {   232,    1,   32},  // 21  1129  0.11%   12.53%  11.54%
  {   256,    1,   32},  // 22  1024  0.02%   12.53%  10.34%
  {   280,    1,   32},  // 23   936  0.05%   12.53%   9.38%
  {   304,    1,   32},  // 24   862  0.06%   12.53%   8.57%
  {   336,    1,   32},  // 25   780  0.05%   12.53%  10.53%
  {   384,    1,   32},  // 26   682  0.12%   12.53%  14.29%
  {   448,    1,   32},  // 27   585  0.05%   12.53%  16.67%
  {   480,    1,   32},  // 28   546  0.05%   12.53%   7.14%
  {   512,    1,   32},  // 29   512  0.02%   12.53%   6.67%
  {   576,    1,   32},  // 30   455  0.05%   12.53%  12.50%
  {   640,    1,   32},  // 31   409  0.17%   12.53%  11.11%
  {   704,    1,   32},  // 32   372  0.12%   12.53%  10.00%
  {   768,    1,   32},  // 33   341  0.12%   12.53%   9.09%
  {   896,    1,   32},  // 34   292  0.22%   12.53%  16.67%
  {  1024,    1,   32},  // 35   256  0.02%   12.53%  14.29%
  {  1152,    1,   32},  // 36   227  0.27%   12.53%  12.50%
  {  1280,    1,   32},  // 37   204  0.41%   12.53%  11.11%
  {  1408,    1,   32},  // 38   186  0.12%   12.53%  10.00%
  {  1664,    1,   32},  // 39   157  0.37%   12.53%  18.18%
  {  1920,    1,   32},  // 40   136  0.41%   12.53%  15.38%
  {  2048,    1,   32},  // 41   128  0.02%   12.53%   6.67%
  {  2304,    1,   28},  // 42   113  0.71%   12.53%  12.50%
  {  2560,    1,   25},  // 43   102  0.41%   12.53%  11.11%
  {  2688,    1,   24},  // 44    97  0.56%   12.53%   5.00%
  {  3072,    1,   21},  // 45    85  0.41%   12.53%  14.29%
  {  3328,    1,   19},  // 46    78  1.00%   12.53%   8.33%
  {  3584,    1,   18},  // 47    73  0.22%   12.53%   7.69%
  {  3840,    1,   17},  // 48    68  0.41%   12.53%   7.14%
  {  4096,    1,   16},  // 49    64  0.02%   12.53%   6.67%
  {  4224,    1,   15},  // 50    62  0.12%   12.53%   3.12%
  {  4480,    1,   14},  // 51    58  0.90%   12.54%   6.06%
  {  4736,    1,   13},  // 52    55  0.66%   12.53%   5.71%
  {  5120,    1,   12},  // 53    51  0.41%   12.53%   8.11%
  {  5504,    1,   11},  // 54    47  1.34%   12.54%   7.50%
  {  6144,    1,   10},  // 55    42  1.59%   12.54%  11.63%
  {  6528,    1,   10},  // 56    40  0.41%   12.53%   6.25%
  {  7168,    1,    9},  // 57    36  1.59%   12.54%   9.80%
  {  8192,    1,    8},  // 58    32  0.02%   12.53%  14.29%
  {  9344,    1,    7},  // 59    28  0.22%   12.53%  14.06%
  { 10368,    1,    6},  // 60    25  1.15%   12.54%  10.96%
  { 11392,    1,    5},  // 61    23  0.07%   12.53%   9.88%
  { 12416,    1,    5},  // 62    21  0.56%   12.54%   8.99%
  { 13696,    1,    4},  // 63    19  0.76%   12.54%  10.31%
  { 15360,    1,    4},  // 64    17  0.41%   12.54%  12.15%
  { 16384,    1,    4},  // 65    16  0.02%   12.53%   6.67%
  { 17408,    1,    3},  // 66    15  0.41%   12.54%   6.25%
  { 18688,    1,    3},  // 67    14  0.22%   12.54%   7.35%
  { 20096,    1,    3},  // 68    13  0.37%   12.54%   7.53%
  { 21760,    1,    3},  // 69    12  0.41%   12.54%   8.28%
  { 23808,    1,    2},  // 70    11  0.12%   12.53%   9.41%
  { 26112,    1,    2},  // 71    10  0.41%   12.54%   9.68%
  { 29056,    1,    2},  // 72     9  0.27%   12.54%  11.27%
  { 32768,    1,    2},  // 73     8  0.02%   12.53%  12.78%
  { 37376,    1,    2},  // 74     7  0.22%   12.54%  14.06%
  { 43648,    1,    2},  // 75     6  0.12%   12.54%  16.78%
  { 45568,    2,    2},  // 76    11  4.41%   12.63%   4.40%
  { 52352,    1,    2},  // 77     5  0.17%   12.54%  14.89%
  { 56064,    2,    2},  // 78     9  3.77%   12.63%   7.09%
  { 65536,    1,    2},  // 79     4  0.02%   12.53%  16.89%
  { 74880,    2,    2},  // 80     7  0.04%   12.53%  14.26%
  { 87296,    1,    2},  // 81     3  0.12%   12.54%  16.58%
  {104832,    2,    2},  // 82     5  0.04%   12.54%  20.09%
  {112256,    3,    2},  // 83     7  0.09%   12.54%   7.08%
  {131072,    1,    2},  // 84     2  0.02%   12.53%  16.76%
  {149760,    3,    2},  // 85     5  4.79%   12.88%  14.26%
  {174720,    2,    2},  // 86     3  0.04%   12.54%  16.67%
  {209664,    4,    2},  // 87     5  0.03%   12.54%  20.00%
  {262144,    1,    2},  // 88     1  0.02%    0.03%  25.03%
};
#elif TCMALLOC_PAGE_SHIFT == 12
static_assert(kMaxSize == 8192, "kMaxSize mismatch");
static constexpr SizeClassAssumptions Assumptions{
  .has_expanded_classes = false,
  .span_size = 64,
  .sampling_interval = 524288,
  .large_size = 1024,
  .large_size_alignment = 128,
};
static constexpr SizeClassInfo List[] = {
//                                         |    waste     |
//  bytes pages batch   class  objs |fixed sampling|    inc
  {     0,    0,    0},  //  0     0  0.00%    0.00%   0.00%
  {     8,    1,   32},  //  1   512  1.54%    0.91%   0.00%
  {    16,    1,   32},  //  2   256  1.54%    0.91% 100.00%
  {    24,    1,   32},  //  3   170  1.92%    0.91%  50.00%
  {    32,    1,   32},  //  4   128  1.54%    0.91%  33.33%
  {    40,    1,   32},  //  5   102  1.92%    0.91%  25.00%
  {    48,    1,   32},  //  6    85  1.92%    0.91%  20.00%
  {    56,    1,   32},  //  7    73  1.73%    0.91%  16.67%
  {    64,    1,   32},  //  8    64  1.54%    0.91%  14.29%
  {    72,    1,   32},  //  9    56  3.08%    0.91%  12.50%
  {    80,    1,   32},  // 10    51  1.92%    0.91%  11.11%
  {    88,    1,   32},  // 11    46  2.69%    0.91%  10.00%
  {    96,    1,   32},  // 12    42  3.08%    0.91%   9.09%
  {   104,    1,   32},  // 13    39  2.50%    0.91%   8.33%
  {   112,    1,   32},  // 14    36  3.08%    0.91%   7.69%
  {   128,    1,   32},  // 15    32  1.54%    0.91%  14.29%
  {   144,    1,   32},  // 16    28  3.08%    0.91%  12.50%
  {   160,    1,   32},  // 17    25  3.85%    0.92%  11.11%
  {   176,    1,   32},  // 18    23  2.69%    0.91%  10.00%
  {   192,    1,   32},  // 19    21  3.08%    0.92%   9.09%
  {   208,    1,   32},  // 20    19  5.00%    0.92%   8.33%
  {   224,    1,   32},  // 21    18  3.08%    0.92%   7.69%
  {   240,    1,   32},  // 22    17  1.92%    0.91%   7.14%
  {   256,    1,   32},  // 23    16  1.54%    0.91%   6.67%
  {   272,    1,   32},  // 24    15  1.92%    0.91%   6.25%
  {   312,    1,   32},  // 25    13  2.50%    0.92%  14.71%
  {   336,    1,   32},  // 26    12  3.08%    0.92%   7.69%
  {   368,    1,   32},  // 27    11  2.69%    0.92%   9.52%
  {   448,    1,   32},  // 28     9  3.08%    0.92%  21.74%
  {   512,    1,   32},  // 29     8  1.54%    0.92%  14.29%
  {   576,    2,   32},  // 30    14  2.33%    0.92%  12.50%
  {   704,    2,   32},  // 31    11  6.20%    0.92%  22.22%
  {   768,    2,   32},  // 32    10  6.98%    0.92%   9.09%
  {   896,    2,   32},  // 33     9  2.33%    0.92%  16.67%
  {  1024,    2,   32},  // 34     8  0.78%    0.92%  14.29%
  {  1152,    3,   32},  // 35    10  6.74%    0.93%  12.50%
  {  1536,    3,   32},  // 36     8  0.52%    0.92%  33.33%
  {  1792,    4,   32},  // 37     9  1.95%    0.92%  16.67%
  {  2048,    4,   32},  // 38     8  0.39%    0.92%  14.29%
  {  2688,    4,   24},  // 39     6  1.95%    0.92%  31.25%
  {  3200,    4,   20},  // 40     5  2.72%    0.93%  19.05%
  {  4096,    4,   16},  // 41     4  0.39%    0.92%  28.00%
  {  4736,    5,   13},  // 42     4  7.79%    1.77%  15.62%
  {  6144,    3,   10},  // 43     2  0.52%    1.70%  29.73%
  {  7168,    7,    9},  // 44     4  0.22%    1.70%  16.67%
  {  8192,    4,    8},  // 45     2  0.39%    1.70%  14.29%
};
#else
#error "Unsupported TCMALLOC_PAGE_SHIFT value!"
#endif
#else
#if TCMALLOC_PAGE_SHIFT == 13
static_assert(kMaxSize == 262144, "kMaxSize mismatch");
static constexpr SizeClassAssumptions Assumptions{
  .has_expanded_classes = true,
  .span_size = 64,
  .sampling_interval = 2097152,
  .large_size = 1024,
  .large_size_alignment = 128,
};
static constexpr SizeClassInfo List[] = {
//                                         |    waste     |
//  bytes pages batch   class  objs |fixed sampling|    inc
  {     0,    0,    0},  //  0     0  0.00%    0.00%   0.00%
  {     8,    1,   32},  //  1  1024  0.78%    0.42%   0.00%
  {    16,    1,   32},  //  2   512  0.78%    0.42% 100.00%
  {    32,    1,   32},  //  3   256  0.78%    0.42% 100.00%
  {    48,    1,   32},  //  4   170  1.16%    0.42%  50.00%
  {    64,    1,   32},  //  5   128  0.78%    0.42%  33.33%
  {    80,    1,   32},  //  6   102  1.16%    0.42%  25.00%
  {    96,    1,   32},  //  7    85  1.16%    0.42%  20.00%
  {   112,    1,   32},  //  8    73  0.97%    0.42%  16.67%
  {   128,    1,   32},  //  9    64  0.78%    0.42%  14.29%
  {   144,    1,   32},  // 10    56  2.33%    0.42%  12.50%
  {   160,    1,   32},  // 11    51  1.16%    0.42%  11.11%
  {   176,    1,   32},  // 12    46  1.94%    0.42%  10.00%
  {   192,    1,   32},  // 13    42  2.33%    0.42%   9.09%
  {   208,    1,   32},  // 14    39  1.74%    0.42%   8.33%
  {   224,    1,   32},  // 15    36  2.33%    0.42%   7.69%
  {   240,    1,   32},  // 16    34  1.16%    0.42%   7.14%
  {   256,    1,   32},  // 17    32  0.78%    0.42%   6.67%
  {   272,    1,   32},  // 18    30  1.16%    0.42%   6.25%
  {   288,    1,   32},  // 19    28  2.33%    0.42%   5.88%
  {   304,    1,   32},  // 20    26  4.26%    0.42%   5.56%
  {   320,    1,   32},  // 21    25  3.10%    0.42%   5.26%
  {   336,    1,   32},  // 22    24  2.33%    0.42%   5.00%
  {   352,    1,   32},  // 23    23  1.94%    0.42%   4.76%
  {   368,    1,   32},  // 24    22  1.94%    0.42%   4.55%
  {   384,    1,   32},  // 25    21  2.33%    0.42%   4.35%
  {   400,    1,   32},  // 26    20  3.10%    0.42%   4.17%
  {   416,    1,   32},  // 27    19  4.26%    0.42%   4.00%
  {   448,    1,   32},  // 28    18  2.33%    0.42%   7.69%
  {   480,    1,   32},  // 29    17  1.16%    0.42%   7.14%
  {   512,    1,   32},  // 30    16  0.78%    0.42%   6.67%
  {   576,    1,   32},  // 31    14  2.33%    0.42%  12.50%
  {   640,    1,   32},  // 32    12  6.98%    0.43%  11.11%
  {   704,    1,   32},  // 33    11  6.20%    0.43%  10.00%
  {   768,    1,   32},  // 34    10  6.98%    0.43%   9.09%
  {   896,    1,   32},  // 35     9  2.33%    0.42%  16.67%
  {  1024,    1,   32},  // 36     8  0.78%    0.42%  14.29%
  {  1152,    2,   32},  // 37    14  1.95%    0.42%  12.50%
  {  1280,    2,   32},  // 38    12  6.61%    0.43%  11.11%
  {  1408,    2,   32},  // 39    11  5.84%    0.43%  10.00%
  {  1536,    2,   32},  // 40    10  6.61%    0.43%   9.09%
  {  1792,    2,   32},  // 41     9  1.95%    0.43%  16.67%
  {  2048,    2,   32},  // 42     8  0.39%    0.42%  14.29%
  {  2304,    2,   28},  // 43     7  1.95%    0.43%  12.50%
  {  2688,    2,   24},  // 44     6  1.95%    0.43%  16.67%
  {  2816,    3,   23},  // 45     8  8.57%    0.44%   4.76%
  {  3200,    2,   20},  // 46     5  2.72%    0.43%  13.64%
  {  3456,    3,   18},  // 47     7  1.82%    0.43%   8.00%
  {  3584,    4,   18},  // 48     9  1.75%    0.43%   3.70%
  {  4096,    1,   16},  // 49     2  0.78%    0.43%  14.29%
  {  4736,    3,   13},  // 50     5  3.90%    0.43%  15.62%
  {  5376,    2,   12},  // 51     3  1.95%    0.43%  13.51%
  {  6144,    3,   10},  // 52     4  0.26%    0.42%  14.29%
  {  6528,    4,   10},  // 53     5  0.58%    0.43%   6.25%
  {  7168,    7,    9},  // 54     8  0.11%    0.42%   9.80%
  {  8192,    1,    8},  // 55     1  0.78%    0.03%  14.29%
  {  9472,    5,    6},  // 56     4  7.64%    0.85%  15.62%
  { 10240,    4,    6},  // 57     3  6.43%    0.85%   8.11%
  { 12288,    3,    5},  // 58     2  0.26%    0.82%  20.00%
  { 13568,    5,    4},  // 59     3  0.78%    0.82%  10.42%
  { 14336,    7,    4},  // 60     4  0.11%    0.82%   5.66%
  { 16384,    2,    4},  // 61     1  0.39%    0.03%  14.29%
  { 20480,    5,    3},  // 62     2  0.16%    1.21%  25.00%
  { 24576,    3,    2},  // 63     1  0.26%    0.03%  20.00%
  { 28672,    7,    2},  // 64     2  0.11%    1.60%  16.67%
  { 32768,    4,    2},  // 65     1  0.19%    0.03%  14.29%
  { 40960,    5,    2},  // 66     1  0.16%    0.03%  25.00%
  { 49152,    6,    2},  // 67     1  0.13%    0.03%  20.00%
  { 57344,    7,    2},  // 68     1  0.11%    0.03%  16.67%
  { 65536,    8,    2},  // 69     1  0.10%    0.03%  14.29%
  { 73728,    9,    2},  // 70     1  0.09%    0.03%  12.50%
  { 81920,   10,    2},  // 71     1  0.08%    0.03%  11.11%
  { 90112,   11,    2},  // 72     1  0.07%    0.03%  10.00%
  { 98304,   12,    2},  // 73     1  0.07%    0.03%   9.09%
  {106496,   13,    2},  // 74     1  0.06%    0.03%   8.33%
  {114688,   14,    2},  // 75     1  0.06%    0.03%   7.69%
  {131072,   16,    2},  // 76     1  0.05%    0.03%  14.29%
  {139264,   17,    2},  // 77     1  0.05%    0.03%   6.25%
  {147456,   18,    2},  // 78     1  0.04%    0.03%   5.88%
  {155648,   19,    2},  // 79     1  0.04%    0.03%   5.56%
  {172032,   21,    2},  // 80     1  0.04%    0.03%  10.53%
  {188416,   23,    2},  // 81     1  0.03%    0.03%   9.52%
  {204800,   25,    2},  // 82     1  0.03%    0.03%   8.70%
  {221184,   27,    2},  // 83     1  0.03%    0.03%   8.00%
  {237568,   29,    2},  // 84     1  0.03%    0.03%   7.41%
  {262144,   32,    2},  // 85     1  0.02%    0.03%  10.34%
};
#elif TCMALLOC_PAGE_SHIFT == 15
static_assert(kMaxSize == 262144, "kMaxSize mismatch");
static constexpr SizeClassAssumptions Assumptions{
  .has_expanded_classes = true,
  .span_size = 64,
  .sampling_interval = 2097152,
  .large_size = 1024,
  .large_size_alignment = 128,
};
static constexpr SizeClassInfo List[] = {
//                                         |    waste     |
//  bytes pages batch   class  objs |fixed sampling|    inc
  {     0,    0,    0},  //  0     0  0.00%    0.00%   0.00%
  {     8,    1,   32},  //  1  4096  0.19%    1.60%   0.00%
  {    16,    1,   32},  //  2  2048  0.19%    1.60% 100.00%
  {    32,    1,   32},  //  3  1024  0.19%    1.60% 100.00%
  {    48,    1,   32},  //  4   682  0.29%    1.60%  50.00%
  {    64,    1,   32},  //  5   512  0.19%    1.60%  33.33%
  {    80,    1,   32},  //  6   409  0.34%    1.60%  25.00%
  {    96,    1,   32},  //  7   341  0.29%    1.60%  20.00%
  {   112,    1,   32},  //  8   292  0.39%    1.60%  16.67%
  {   128,    1,   32},  //  9   256  0.19%    1.60%  14.29%
  {   144,    1,   32},  // 10   227  0.44%    1.60%  12.50%
  {   160,    1,   32},  // 11   204  0.58%    1.60%  11.11%
  {   176,    1,   32},  // 12   186  0.29%    1.60%  10.00%
  {   192,    1,   32},  // 13   170  0.58%    1.60%   9.09%
  {   208,    1,   32},  // 14   157  0.54%    1.60%   8.33%
  {   224,    1,   32},  // 15   146  0.39%    1.60%   7.69%
  {   240,    1,   32},  // 16   136  0.58%    1.60%   7.14%
  {   256,    1,   32},  // 17   128  0.19%    1.60%   6.67%
  {   288,    1,   32},  // 18   113  0.88%    1.60%  12.50%
  {   320,    1,   32},  // 19   102  0.58%    1.60%  11.11%
  {   352,    1,   32},  // 20    93  0.29%    1.60%  10.00%
  {   384,    1,   32},  // 21    85  0.58%    1.60%   9.09%
  {   400,    1,   32},  // 22    81  1.32%    1.60%   4.17%
  {   448,    1,   32},  // 23    73  0.39%    1.60%  12.00%
  {   480,    1,   32},  // 24    68  0.58%    1.60%   7.14%
  {   512,    1,   32},  // 25    64  0.19%    1.60%   6.67%
  {   576,    1,   32},  // 26    56  1.75%    1.60%  12.50%
  {   640,    1,   32},  // 27    51  0.58%    1.60%  11.11%
  {   704,    1,   32},  // 28    46  1.36%    1.60%  10.00%
  {   768,    1,   32},  // 29    42  1.75%    1.60%   9.09%
  {   832,    1,   32},  // 30    39  1.17%    1.60%   8.33%
  {   896,    1,   32},  // 31    36  1.75%    1.60%   7.69%
  {  1024,    1,   32},  // 32    32  0.19%    1.60%  14.29%
  {  1152,    1,   32},  // 33    28  1.75%    1.60%  12.50%
  {  1280,    1,   32},  // 34    25  2.53%    1.60%  11.11%
  {  1408,    1,   32},  // 35    23  1.36%    1.60%  10.00%
  {  1536,    1,   32},  // 36    21  1.75%    1.60%   9.09%
  {  1664,    1,   32},  // 37    19  3.70%    1.60%   8.33%
  {  1792,    1,   32},  // 38    18  1.75%    1.60%   7.69%
  {  1920,    1,   32},  // 39    17  0.58%    1.60%   7.14%
  {  2048,    1,   32},  // 40    16  0.19%    1.60%   6.67%
  {  2176,    1,   30},  // 41    15  0.58%    1.60%   6.25%
  {  2304,    1,   28},  // 42    14  1.75%    1.60%   5.88%
  {  2432,    1,   26},  // 43    13  3.70%    1.60%   5.56%
  {  2688,    1,   24},  // 44    12  1.75%    1.60%  10.53%
  {  2944,    1,   22},  // 45    11  1.36%    1.60%   9.52%
  {  3200,    1,   20},  // 46    10  2.53%    1.60%   8.70%
  {  3584,    1,   18},  // 47     9  1.75%    1.60%  12.00%
  {  4096,    1,   16},  // 48     8  0.19%    1.60%  14.29%
  {  4608,    1,   14},  // 49     7  1.75%    1.60%  12.50%
  {  5376,    1,   12},  // 50     6  1.75%    1.60%  16.67%
  {  6528,    1,   10},  // 51     5  0.58%    1.60%  21.43%
  {  7168,    2,    9},  // 52     9  1.66%    1.60%   9.80%
  {  8192,    1,    8},  // 53     4  0.19%    1.60%  14.29%
  {  9344,    2,    7},  // 54     7  0.29%    1.60%  14.06%
  { 10880,    1,    6},  // 55     3  0.58%    1.60%  16.44%
  { 13056,    2,    5},  // 56     5  0.49%    1.60%  20.00%
  { 13952,    3,    4},  // 57     7  0.72%    1.60%   6.86%
  { 16384,    1,    4},  // 58     2  0.19%    1.60%  17.43%
  { 19072,    3,    3},  // 59     5  3.06%    1.62%  16.41%
  { 21760,    2,    3},  // 60     3  0.49%    1.60%  14.09%
  { 24576,    3,    2},  // 61     4  0.07%    1.60%  12.94%
  { 26112,    4,    2},  // 62     5  0.44%    1.60%   6.25%
  { 28672,    7,    2},  // 63     8  0.03%    1.60%   9.80%
  { 32768,    1,    2},  // 64     1  0.19%    0.03%  14.29%
  { 38144,    5,    2},  // 65     4  6.91%    3.28%  16.41%
  { 40960,    4,    2},  // 66     3  6.30%    3.28%   7.38%
  { 49152,    3,    2},  // 67     2  0.07%    3.16%  20.00%
  { 57344,    7,    2},  // 68     4  0.03%    3.16%  16.67%
  { 65536,    2,    2},  // 69     1  0.10%    0.03%  14.29%
  { 81920,    5,    2},  // 70     2  0.04%    4.72%  25.00%
  { 98304,    3,    2},  // 71     1  0.07%    0.03%  20.00%
  {114688,    7,    2},  // 72     2  0.03%    6.28%  16.67%
  {131072,    4,    2},  // 73     1  0.05%    0.03%  14.29%
  {163840,    5,    2},  // 74     1  0.04%    0.03%  25.00%
  {196608,    6,    2},  // 75     1  0.03%    0.03%  20.00%
  {229376,    7,    2},  // 76     1  0.03%    0.03%  16.67%
  {262144,    8,    2},  // 77     1  0.02%    0.03%  14.29%
};
#elif TCMALLOC_PAGE_SHIFT == 18
static_assert(kMaxSize == 262144, "kMaxSize mismatch");
static constexpr SizeClassAssumptions Assumptions{
  .has_expanded_classes = true,
  .span_size = 64,
  .sampling_interval = 2097152,
  .large_size = 1024,
  .large_size_alignment = 128,
};
static constexpr SizeClassInfo List[] = {
//                                         |    waste     |
//  bytes pages batch   class  objs |fixed sampling|    inc
  {     0,    0,    0},  //  0     0  0.00%    0.00%   0.00%
  {     8,    1,   32},  //  1 32768  0.02%   12.53%   0.00%
  {    16,    1,   32},  //  2 16384  0.02%   12.53% 100.00%
  {    32,    1,   32},  //  3  8192  0.02%   12.53% 100.00%
  {    48,    1,   32},  //  4  5461  0.03%   12.53%  50.00%
  {    64,    1,   32},  //  5  4096  0.02%   12.53%  33.33%
  {    80,    1,   32},  //  6  3276  0.05%   12.53%  25.00%
  {    96,    1,   32},  //  7  2730  0.05%   12.53%  20.00%
  {   112,    1,   32},  //  8  2340  0.05%   12.53%  16.67%
  {   128,    1,   32},  //  9  2048  0.02%   12.53%  14.29%
  {   144,    1,   32},  // 10  1820  0.05%   12.53%  12.50%
  {   160,    1,   32},  // 11  1638  0.05%   12.53%  11.11%
  {   176,    1,   32},  // 12  1489  0.05%   12.53%  10.00%
  {   192,    1,   32},  // 13  1365  0.05%   12.53%   9.09%
  {   208,    1,   32},  // 14  1260  0.05%   12.53%   8.33%
  {   224,    1,   32},  // 15  1170  0.05%   12.53%   7.69%
  {   240,    1,   32},  // 16  1092  0.05%   12.53%   7.14%
  {   256,    1,   32},  // 17  1024  0.02%   12.53%   6.67%
  {   272,    1,   32},  // 18   963  0.10%   12.53%   6.25%
  {   304,    1,   32},  // 19   862  0.06%   12.53%  11.76%
  {   336,    1,   32},  // 20   780  0.05%   12.53%  10.53%
  {   384,    1,   32},  // 21   682  0.12%   12.53%  14.29%
  {   416,    1,   32},  // 22   630  0.05%   12.53%   8.33%
  {   448,    1,   32},  // 23   585  0.05%   12.53%   7.69%
  {   480,    1,   32},  // 24   546  0.05%   12.53%   7.14%
  {   512,    1,   32},  // 25   512  0.02%   12.53%   6.67%
  {   576,    1,   32},  // 26   455  0.05%   12.53%  12.50%
  {   640,    1,   32},  // 27   409  0.17%   12.53%  11.11%
  {   704,    1,   32},  // 28   372  0.12%   12.53%  10.00%
  {   768,    1,   32},  // 29   341  0.12%   12.53%   9.09%
  {   896,    1,   32},  // 30   292  0.22%   12.53%  16.67%
  {  1024,    1,   32},  // 31   256  0.02%   12.53%  14.29%
  {  1152,    1,   32},  // 32   227  0.27%   12.53%  12.50%
  {  1280,    1,   32},  // 33   204  0.41%   12.53%  11.11%
  {  1408,    1,   32},  // 34   186  0.12%   12.53%  10.00%
  {  1536,    1,   32},  // 35   170  0.41%   12.53%   9.09%
  {  1664,    1,   32},  // 36   157  0.37%   12.53%   8.33%
  {  1920,    1,   32},  // 37   136  0.41%   12.53%  15.38%
  {  2048,    1,   32},  // 38   128  0.02%   12.53%   6.67%
  {  2304,    1,   28},  // 39   113  0.71%   12.53%  12.50%
  {  2560,    1,   25},  // 40   102  0.41%   12.53%  11.11%
  {  2688,    1,   24},  // 41    97  0.56%   12.53%   5.00%
  {  3072,    1,   21},  // 42    85  0.41%   12.53%  14.29%
  {  3328,    1,   19},  // 43    78  1.00%   12.53%   8.33%
  {  3584,    1,   18},  // 44    73  0.22%   12.53%   7.69%
  {  3840,    1,   17},  // 45    68  0.41%   12.53%   7.14%
  {  4096,    1,   16},  // 46    64  0.02%   12.53%   6.67%
  {  4224,    1,   15},  // 47    62  0.12%   12.53%   3.12%
  {  4480,    1,   14},  // 48    58  0.90%   12.54%   6.06%
  {  4736,    1,   13},  // 49    55  0.66%   12.53%   5.71%
  {  5120,    1,   12},  // 50    51  0.41%   12.53%   8.11%
  {  5504,    1,   11},  // 51    47  1.34%   12.54%   7.50%
  {  6144,    1,   10},  // 52    42  1.59%   12.54%  11.63%
  {  6528,    1,   10},  // 53    40  0.41%   12.53%   6.25%
  {  7168,    1,    9},  // 54    36  1.59%   12.54%   9.80%
  {  8192,    1,    8},  // 55    32  0.02%   12.53%  14.29%
  {  8704,    1,    7},  // 56    30  0.41%   12.53%   6.25%
  {  9344,    1,    7},  // 57    28  0.22%   12.53%   7.35%
  { 10368,    1,    6},  // 58    25  1.15%   12.54%  10.96%
  { 11392,    1,    5},  // 59    23  0.07%   12.53%   9.88%
  { 12416,    1,    5},  // 60    21  0.56%   12.54%   8.99%
  { 13056,    1,    5},  // 61    20  0.41%   12.54%   5.15%
  { 13696,    1,    4},  // 62    19  0.76%   12.54%   4.90%
  { 15360,    1,    4},  // 63    17  0.41%   12.54%  12.15%
  { 16384,    1,    4},  // 64    16  0.02%   12.53%   6.67%
  { 17408,    1,    3},  // 65    15  0.41%   12.54%   6.25%
  { 18688,    1,    3},  // 66    14  0.22%   12.54%   7.35%
  { 20096,    1,    3},  // 67    13  0.37%   12.54%   7.53%
  { 21760,    1,    3},  // 68    12  0.41%   12.54%   8.28%
  { 23808,    1,    2},  // 69    11  0.12%   12.53%   9.41%
  { 26112,    1,    2},  // 70    10  0.41%   12.54%   9.68%
  { 29056,    1,    2},  // 71     9  0.27%   12.54%  11.27%
  { 32768,    1,    2},  // 72     8  0.02%   12.53%  12.78%
  { 37376,    1,    2},  // 73     7  0.22%   12.54%  14.06%
  { 43648,    1,    2},  // 74     6  0.12%   12.54%  16.78%
  { 45568,    2,    2},  // 75    11  4.41%   12.63%   4.40%
  { 52352,    1,    2},  // 76     5  0.17%   12.54%  14.89%
  { 56064,    2,    2},  // 77     9  3.77%   12.63%   7.09%
  { 65536,    1,    2},  // 78     4  0.02%   12.53%  16.89%
  { 74880,    2,    2},  // 79     7  0.04%   12.53%  14.26%
  { 87296,    1,    2},  // 80     3  0.12%   12.54%  16.58%
  {104832,    2,    2},  // 81     5  0.04%   12.54%  20.09%
  {112256,    3,    2},  // 82     7  0.09%   12.54%   7.08%
  {131072,    1,    2},  // 83     2  0.02%   12.53%  16.76%
  {149760,    3,    2},  // 84     5  4.79%   12.88%  14.26%
  {174720,    2,    2},  // 85     3  0.04%   12.54%  16.67%
  {196608,    3,    2},  // 86     4  0.01%   12.53%  12.53%
  {209664,    4,    2},  // 87     5  0.03%   12.54%   6.64%
  {262144,    1,    2},  // 88     1  0.02%    0.03%  25.03%
};
#elif TCMALLOC_PAGE_SHIFT == 12
static_assert(kMaxSize == 8192, "kMaxSize mismatch");
static constexpr SizeClassAssumptions Assumptions{
  .has_expanded_classes = false,
  .span_size = 64,
  .sampling_interval = 524288,
  .large_size = 1024,
  .large_size_alignment = 128,
};
static constexpr SizeClassInfo List[] = {
//                                         |    waste     |
//  bytes pages batch   class  objs |fixed sampling|    inc
  {     0,    0,    0},  //  0     0  0.00%    0.00%   0.00%
  {     8,    1,   32},  //  1   512  1.54%    0.91%   0.00%
  {    16,    1,   32},  //  2   256  1.54%    0.91% 100.00%
  {    32,    1,   32},  //  3   128  1.54%    0.91% 100.00%
  {    48,    1,   32},  //  4    85  1.92%    0.91%  50.00%
  {    64,    1,   32},  //  5    64  1.54%    0.91%  33.33%
  {    80,    1,   32},  //  6    51  1.92%    0.91%  25.00%
  {    96,    1,   32},  //  7    42  3.08%    0.91%  20.00%
  {   112,    1,   32},  //  8    36  3.08%    0.91%  16.67%
  {   128,    1,   32},  //  9    32  1.54%    0.91%  14.29%
  {   144,    1,   32},  // 10    28  3.08%    0.91%  12.50%
  {   160,    1,   32},  // 11    25  3.85%    0.92%  11.11%
  {   176,    1,   32},  // 12    23  2.69%    0.91%  10.00%
  {   192,    1,   32},  // 13    21  3.08%    0.92%   9.09%
  {   208,    1,   32},  // 14    19  5.00%    0.92%   8.33%
  {   224,    1,   32},  // 15    18  3.08%    0.92%   7.69%
  {   240,    1,   32},  // 16    17  1.92%    0.91%   7.14%
  {   256,    1,   32},  // 17    16  1.54%    0.91%   6.67%
  {   272,    1,   32},  // 18    15  1.92%    0.91%   6.25%
  {   288,    1,   32},  // 19    14  3.08%    0.92%   5.88%
  {   304,    1,   32},  // 20    13  5.00%    0.92%   5.56%
  {   336,    1,   32},  // 21    12  3.08%    0.92%  10.53%
  {   368,    1,   32},  // 22    11  2.69%    0.92%   9.52%
  {   448,    1,   32},  // 23     9  3.08%    0.92%  21.74%
  {   512,    1,   32},  // 24     8  1.54%    0.92%  14.29%
  {   576,    2,   32},  // 25    14  2.33%    0.92%  12.50%
  {   640,    2,   32},  // 26    12  6.98%    0.92%  11.11%
  {   704,    2,   32},  // 27    11  6.20%    0.92%  10.00%
  {   768,    2,   32},  // 28    10  6.98%    0.92%   9.09%
  {   896,    2,   32},  // 29     9  2.33%    0.92%  16.67%
  {  1024,    2,   32},  // 30     8  0.78%    0.92%  14.29%
  {  1152,    3,   32},  // 31    10  6.74%    0.93%  12.50%
  {  1280,    3,   32},  // 32     9  6.74%    0.93%  11.11%
  {  1536,    3,   32},  // 33     8  0.52%    0.92%  20.00%
  {  1792,    4,   32},  // 34     9  1.95%    0.92%  16.67%
  {  2048,    4,   32},  // 35     8  0.39%    0.92%  14.29%
  {  2304,    4,   28},  // 36     7  1.95%    0.92%  12.50%
  {  2688,    4,   24},  // 37     6  1.95%    0.92%  16.67%
  {  3200,    4,   20},  // 38     5  2.72%    0.93%  19.05%
  {  3584,    7,   18},  // 39     8  0.22%    0.92%  12.00%
  {  4096,    4,   16},  // 40     4  0.39%    0.92%  14.29%
  {  4736,    5,   13},  // 41     4  7.79%    1.77%  15.62%
  {  5376,    4,   12},  // 42     3  1.95%    1.72%  13.51%
  {  6144,    3,   10},  // 43     2  0.52%    1.70%  14.29%
  {  7168,    7,    9},  // 44     4  0.22%    1.70%  16.67%
  {  8192,    4,    8},  // 45     2  0.39%    1.70%  14.29%
};
#else
#error "Unsupported TCMALLOC_PAGE_SHIFT value!"
#endif
#endif
// clang-format on

static_assert(sizeof(List) / sizeof(List[0]) <= kNumBaseClasses);
extern constexpr SizeClasses kLegacySizeClasses{List, Assumptions};

}  // namespace tcmalloc_internal
}  // namespace tcmalloc
GOOGLE_MALLOC_SECTION_END
